package com.agile.leetcode.url;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/5/21 19:07
 */
public class UrlConnection {
    public static void main(String[] args) throws Exception{
        // 直接请求接口
        URL url = new URL("http://localhost:8083/czk/dept/1");
        // 拿到输入流
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()));
        String content;
        while ((content = bufferedReader.readLine()) != null) {
            System.out.println(content);
        }

    }
}
